package com.atguigu.rabbit.producer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject: rabbitmq-parent-0528
 * @BelongsPackage: com.atguigu.rabbit.producer.config
 * @Author: jiangyi
 * @CreateTime: 2025-09-15  11:46
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
public class RabbitmqDirectExchangeConfiguration {

    @Bean
    public Exchange directExchange(){
        // 创建direct交换机
        return ExchangeBuilder.directExchange("direct_exchange").durable(true).build();
    }

    @Bean
    public Queue directQueue01(){
        // 创建队列
        return new Queue("direct_queue_01",true);
    }


    // 声明队列和交换机的绑定信息
    @Bean
    public Binding directQueue01Binding() {
        Binding binding = BindingBuilder.bind(directQueue01()).to(directExchange())
                .with("info").noargs();
        return binding ;
    }

}
